package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteBeanUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalServiceOfferConsts;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 设备类转商用
 */
public class LocalOrderCommercialAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data) {
        // 转商用业务
        if (LocalServiceOfferConsts.SERVICE_OFFER_COMMERCIAL.equals(data.getServiceOfferId())) {
            String fieldNameString = "200003931,200003932,200003933,200003934,200003935,200004085,200004086,200004087,200004088,200004089,200004090,200004166";
            // 显示
            List<String> fieldNames = Arrays.asList(fieldNameString.split(","));
            fieldNames.forEach(fieldName -> {
                KiteAttr targetAttr = inst.getAttr(fieldName);
                if (Objects.nonNull(targetAttr)) {
                    targetAttr.setShowType("D");
                }
            });
            // 隐藏
            KiteAttr experienceTimeAttr = inst.getAttr("200004102");
            if (Objects.nonNull(experienceTimeAttr)) {
                experienceTimeAttr.setShowType("H");
            }
            KiteAttr platTypeAttr = inst.getAttr("200004101");
            if (Objects.nonNull(platTypeAttr)) {
                platTypeAttr.setShowType("H");
            }
        }

    }
}
